package game.sprite;

import engine.j2d.Image;
import engine.j2d.Rectangle;

public class Sprite2D implements Sprite
{
	private Image SpriteImage;
	private float x = 0 ;
	private float y = 0 ;
	private Rectangle me = new Rectangle();
	private Rectangle him = new Rectangle();

	public Sprite2D(String ref)
	{
		this(ref, 0, 0);
	}

	public Sprite2D(String ref, float x, float y)
	{
		SpriteImage = new Image(ref);
		this.x = x;
		this.y = y;
	}

	public void setX(float x)
	{
		this.x = x;
	}

	public void setY(float y)
	{
		this.y = y;
	}

	public void setPoint(float x, float y)
	{
		this.x = x;
		this.y = y;
	}

	public float getX()
	{
		return x;
	}

	public float getY()
	{
		return y;
	}

	public void moveX(float speed)
	{
		x += speed;
	}

	public void moveY(float speed)
	{
		y += speed;
	}

	public void render(float x_pos, float y_pos)
	{
		SpriteImage.draw(x + x_pos, y + y_pos);
	}

	public void render()
	{
		SpriteImage.draw(x, y);
	}

	public float getHeight()
	{
		return SpriteImage.getHeight() - (SpriteImage.getHeight() / 11);
	}

	public float getWidth()
	{
		return SpriteImage.getWidth() - (SpriteImage.getWidth() / 11);
	}

	public boolean collide(Sprite other)
	{
		me.setBounds(x, y, getWidth(), getHeight());
		him.setBounds(other.getX(), other.getY(), other.getWidth(), other
				.getHeight());
		return me.intersects(him);
	}

	public boolean getSpriteArte()
	{
		return false;
	}

	@Override
	@SuppressWarnings("unused")
	public void setFrame(int counImagesOnX, int countImagesOnY, int nspeed,
			boolean loop) {
		// do nothing
	}
}
